package com.ng.framework.view.desktop.filters;

import java.util.List;

import javax.swing.JComboBox;

import com.ng.framework.persistence.NGSearchParameter.Type;
import com.ng.framework.persistence.NGSearchParameter.UnaryOperation;

public abstract class NGJComboBoxFilter<T> extends NGSimpleFilter<JComboBox> {
	
	private static final long serialVersionUID = -6872019167276131724L;

	public NGJComboBoxFilter(String name, Class<?> clazz, String attribute,
			Type type, UnaryOperation unaryOperation, List<T> comboContent) {
		this(name, clazz, attribute, type, unaryOperation, null, comboContent);
	}
	
	public NGJComboBoxFilter(String name, Class<?> clazz, String attribute,
			Type type, UnaryOperation unaryOperation, String joinAttribute, List<T> comboContent) {
		super(name, clazz, attribute, type, unaryOperation, joinAttribute);
		
		this.getComponent().addItem(null);
		for(T item : comboContent) {
			this.getComponent().addItem(item);
		}
	}

	@Override
	protected JComboBox createComponent() {
		JComboBox comboBox = new JComboBox();
		comboBox.setPrototypeDisplayValue("W");
//		BoundsPopupMenuListener listener = new BoundsPopupMenuListener(true, false);
//		comboBox.addPopupMenuListener(listener);
		return comboBox;
	}

	@Override
	public void clear() {
		this.getComponent().setSelectedItem(null);
	}

}
